package com.aaa.cts.redission;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.redisson.api.RBucket;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
@Component
public class RedissonTest {

    @Autowired
    private RedissonClient redissonClient;

    @Test
    public void set() {
        // 设置字符串
        RBucket<String> keyObj = redissonClient.getBucket("k1");
        /*RLock k1 = redissonClient.getLock("k1");
        k1.lock();
        k1.unlock();*/
        keyObj.set("v1236");
        RBucket<Object> k1 = redissonClient.getBucket("k1");
        System.out.println(k1.get());
        redissonClient.shutdown();
    }

}
